class Blog::AdminPostsController < AdminController

  layout 'admin/blog'

  def index
    @posts = Post.find :all, :order => 'created_at DESC'
    @friendblog = Friendblog.new
  end

  def new
    @post = Post.new
  end

  def show
    @post = Post.find(params[:id])
  end

  def edit
    show
  end

  def update
    @post = Post.find(params[:id])
    if @post.update_attributes(params['post'])
      redirect_to blog_admin_post_path(@post)
    else
      render :action => 'edit'
    end
  end

  def create
    @post = Post.new(params['post'])
    if @post.save
      redirect_to blog_admin_post_path(@post)
    else
      render :action => 'new'
    end
  end

  def destroy
    post = Post.find params['id']
    post.destroy
    redirect_to blog_admin_posts_path
  end

end
